/*
struct ListNode {
    int val;
    struct ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};*/
class PalindromeList {
public:
    struct ListNode* MiddleNode(ListNode* head)
    {
        struct ListNode* slow = head, * fast = head;
        while (fast && fast->next)
        {
            fast = fast->next->next;
            slow = slow->next;
        }
        return slow;
    }
    struct ListNode* reverseNode(ListNode* head)
    {
        struct ListNode* cur = head, * next, * Node = NULL;
        while (cur)
        {
            next = cur->next;
            cur->next = Node;
            Node = cur;
            cur = next;
            if (next)
                next = next->next;
        }
        return Node;
    }
    bool chkPalindrome(ListNode* head)
    {
        struct ListNode* start = head, * middle;
        middle = MiddleNode(head);
        middle = reverseNode(middle);
        while (middle)
        {
            if (start->val != middle->val)
            {
                return false;;
            }
            start = start->next;
            middle = middle->next;
        }
        return true;
    }
};